﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core
{
    public static partial class functional
    {
        public static string toTimeString(this DateTime time)
        {
            return string.Format("{0:yyyy-M-d H:m:s}", time);
        }

        public static string toTimeString(this DateTime? time)
        {
            return time.HasValue ? string.Format("{0:yyyy-M-d H:m:s}", time) : null;
        }

        public static string toDateString(this DateTime time)
        {
            return string.Format("{0:yyyy-M-d}", time);
        }

        public static string toDateString(this DateTime? time)
        {
            return time.HasValue ? string.Format("{0:yyyy-M-d}", time) : null;
        }

        public static int toSex(this bool? sex)
        {
            return sex.HasValue ? sex.Value ? 1 : 2 : 0;
        }
        public static int toSex(this bool sex)
        {
            return sex ? 1 : 2;
        }
    }
}
